var express = require('express');
var router = express.Router();
var retUtil = require('../util/retUtil');
var promoterUtil = require('./util/promoterUtil');

router.get('/ck', function(req, res, next) {
    res.json({'ok':':)'});
});

/*
*
* 给使用推荐码的用户发放收益
* 发放推荐码拥有者收益 2018-7-19号修改增加该接口的功能
*
*
* @author 王俊
* @date 2018-07-10
*
* 参数: actId     活动唯一标识
*
* 接口地址: http://yapi.yijianxiu.com:7000/project/34/interface/api/3835
* */
function distributeIncomeForPromoterCoderUser(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    var actId = retUtil.numberFromReq(req, 'actId');
    if(!actId || actId <=0) {
        return retUtil.ret_err_json('参数错误', res);
    }
    var opt = {
        actId : actId
    };
    promoterUtil.distributeIncomeForPromoterCoderUser(opt, function (error, data) {
        if(error) {
            return retUtil.ret_err_json(error, res);
        }
        return retUtil.ret_succ_json(data, res);
    });
}
router.get('/distributeIncomeForPromoterCoderUser', distributeIncomeForPromoterCoderUser);
router.post('/distributeIncomeForPromoterCoderUser', distributeIncomeForPromoterCoderUser);


module.exports = router;
